<template>
	<view class="recruit">
		<!-- 导航 -->
		<u-navbar back-text="团长营销" :back-text-style="textStyle" back-icon-color="#000000" style="font-weight: bold;font-family: PingFang SC;"></u-navbar>
		<!-- end -->
		<view style="width: 100%;">
			<!-- 头部开始 -->
			<view style="width: 92%;margin: 0 auto;">
				<view style="line-height: 60rpx;font-weight: 500;font-size: 30rpx;">营销文案</view>
				<view class="problem"><textarea class="p-20" placeholder="请联系平台配置营销文案" disabled maxlength="150" v-model="desc" /></view>
			</view>
			<view @click="copyText" style="width: 88%;margin: 0 auto;height: 75rpx;line-height: 75rpx; margin: 0 auto;background: linear-gradient(146deg, #FF6F02 0%, #FFA200 100%);font-size: 32rpx;text-align: center;border-radius: 50rpx;color: #fff;">
				复制文案
			</view>
			<!-- 头部开始结束 -->
			<!-- 产品内容开始 -->
			<!-- <view style="width: 92%;margin: 0 auto;" v-if="list.length > 0">
				<view style="line-height: 60rpx;font-weight: 500;font-size: 30rpx;    padding: 30rpx 0 15rpx 0;">营销视频</view>
				<view style="width: 100%;display: flex;flex-wrap: wrap;justify-content: space-between;">
					<view style="width: 48%;margin-bottom: 30rpx;" v-for="(item,index) in list" :key="index">
						<view style="position: relative;">
							<video :src="item.videoUrl" style="width: 100%;height: 180rpx;" controls></video>
							<view style="opacity: 0.8; color: #000;background-color: #B8B8B8;position: absolute;bottom:6rpx ;width: 100%;height: 40rpx;line-height: 40rpx;text-align: center;">
								{{item.videoName}}
							</view>
						</view>
						<view @click="downloadFile(item.videoUrl)" style="width: 100%;margin: 0 auto;height: 50rpx;line-height: 50rpx; margin: 0 auto;background: linear-gradient(146deg, #FF6F02 0%, #FFA200 100%);font-size: 28rpx;text-align: center;border-radius: 6rpx;color: #fff;">
							下载视频
						</view>
					</view>
				</view>
			</view> -->
			<!-- 产品内容结束 -->
			<!-- 模态框 -->
			<u-modal v-model="showModelMask" confirm-color="#FF7900" :content="content"></u-modal>
			<!-- 模态框结束 -->
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			desc:"",
			showModelMask: false, //模态框内容
			content: '', //模态框文本
			background: {
				backgroundColor: '#fca800'
			},
			list:[],
		};
	},
	onLoad() {
		//获取营销文案
		this.getMarketingProgram();
		//获取营销视频
		this.getMarketing();
	},
	onShow() {},
	methods: {
		copyText(){
			uni.setClipboardData({  
				data: this.desc
			})
		},
		//获取营销视频
		getMarketing(){
			var _this = this;
			let opts = {
				way: true,
				method: 'post',
				url: 'chiefRecruit/getChiefMarketing'
			};
			let data = _this.form;
			_this.http.httpTokenRequest(opts, data).then(res => {
				if (res.code == 200) {
					this.list=res.data;
				} else {
					uni.showToast({
						title: res.message,
						mask: true,
						icon: 'none',
						duration: 2000
					});
				}
			});
		},
		//获取营销文案
		getMarketingProgram(){
			var _this = this;
			let opts = {
				way: true,
				method: 'post',
				url: 'chiefRecruit/getMarketingProgram'
			};
			let data = _this.form;
			_this.http.httpTokenRequest(opts, data).then(res => {
				if (res.code == 200) {
					this.desc=res.data;
				} else {
					uni.showToast({
						title: res.message,
						mask: true,
						icon: 'none',
						duration: 2000
					});
				}
			});
		},
		// 保存视频到本地
		downloadFile(url){
			uni.showLoading({
			  title: '正在保存',
			})
			uni.downloadFile({
			  url: url, //仅为示例，并非真实的资源
			  success (res) {
			    // 只要服务器有响应数据，就会把响应内容写入文件并进入 success 回调，业务需要自行判断是否下载到了想要的内容
			    if (res.statusCode === 200) {
					console.log(res)
					uni.hideLoading()
					uni.showToast({
						title: "保存成功",
						mask: true,
						icon: 'none',
						duration: 1000
					});
			    }else{
					uni.hideLoading()
					uni.showToast({
						title: "保存失败",
						mask: true,
						icon: 'none',
						duration: 1000
					});
				}
			  },fail(res){
				  uni.hideLoading()
				  uni.showToast({
				  	title: "保存失败",
				  	mask: true,
				  	icon: 'none',
				  	duration: 1000
				  });
			  }
			 });
		},
	}
};
</script>

<style scoped lang="scss">
.recruit {
	padding: 0;
	margin: 0;
	width: 100%;
	overflow: hidden;
}
.problem {
	padding: 15rpx 0;
}
.p-20 {
	border: 1px solid #E9E9E9;
	padding: 14rpx 24rpx;
	font-size: 30rpx;
	color: #2F2D2B;
	font-family: PingFang SC;
	font-weight: 400;
	line-height: 21rpx;
	width:92%;
	border-radius: 10rpx;
}
</style>
